<html>
<head>
<title>AJAX test</title>
</head>
<body>
<script type="text/javascript">

function xml_http_post(url, data, callback) {
	var req = false;
    try {
    	// Firefox, Opera 8.0+, Safari
        req = new XMLHttpRequest();
    } catch (e) {
    	// Internet Explorer
        try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
        	try {
            	req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
            	alert("Your browser does not support AJAX!");
                return false;
            }
        }
	}
    req.open("POST", url, true);
    req.onreadystatechange = function() {
	    if (req.readyState == 4) {
	    	callback(req);
	    }
	}
    req.send(data);
}

function foo() {
	// JSLINT
	new Ajax.Updater(
		parentSelectBox, 
		ajaxurl, 
		{
			postBody: postBodyStr,
			evalScripts: true,
			onComplete: function() {
				changeSelectBoxPosition();
			}
		}
	);
}

// generate image
function fetchImage() {
    var data = document.test_form.image_id.value;           
    xml_http_post("frontend.html", data, setImage_handle)
}

function setImage_handle(req) {
        var elem = document.getElementById('image_output')
        elem.innerHTML =  req.responseText
}

</script>

<form name="test_form" action="frontend.html" method="post">
Image id: 
<input type="text" name="image_id" value="0" size="9">


<input type=button value="fetch" title="fetch">
</form>
</hr>
<span id="image_output">0</span>
</body>
</html>
